package com.glsc.ngateway.common.base.repo.mysql.opmanage.report.regulatory;

import com.glsc.ngateway.common.base.domain.mysql.opmanage.report.regulatory.RegRptCheckRulesDefine;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * @author: qiyr
 * @date: 2022/7/5 10:09
 * @description: 监管报表校验规则定义数据访问层
 */
@Repository
public interface RegRptCheckRulesDefineRepo extends JpaRepository<RegRptCheckRulesDefine, BigInteger>, JpaSpecificationExecutor<RegRptCheckRulesDefine> {

    @Query(value = "select" +
            "           trrcd.*" +
            "       from" +
            "           glsc_data.t_reg_rpt_checkrules_define trrcd" +
            "       join" +
            "           glsc_data.t_reg_rpt_define trrd on" +
            "           trrd.id = trrcd.rpt_define_id" +
            "       join glsc_data.t_import_match tim on" +
            "           trrd.import_config_id = tim.fl_importid" +
            "       where" +
            "           tim.fc_catid = :catId" +
            "           and trrcd.del_flag = 0" +
            "       order by" +
            "           trrcd.rpt_define_id, trrcd.id", nativeQuery = true)
    List<RegRptCheckRulesDefine> findListByCatId(@Param("catId") String catId);

    @Query(value = "select * from glsc_data.t_reg_rpt_checkrules_define where del_flag = 0", nativeQuery = true)
    List<RegRptCheckRulesDefine> findAllExist();
}
